package com.tourism.controller;

import com.github.pagehelper.PageInfo;
import com.tourism.entity.Line;
import com.tourism.entity.Room;
import com.tourism.entity.RoomQuery;
import com.tourism.service.RoomService;
import com.tourism.util.common.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @Description 房间相关的控制器
 * @Author z
 * @Date 2021-03-01 20:40
 */
@Controller
@RequestMapping("/room")
public class RoomController {


    @Autowired
    private RoomService roomService;

    /**
     * 根据房间id查询房间信息
     *
     * @param id
     * @return
     */
    @GetMapping("/getRoomById")
    @ResponseBody
    public Room getRoomById(Long id) {
        return roomService.getRoomById(id);
    }

    /**
     * 根据房间id删除房间信息
     *
     * @param id
     * @return
     */
    @DeleteMapping("/deleteRoomById")
    @ResponseBody
    public Response deleteRoomById(Long id) {
        return Response.success(roomService.deleteRoomById(id));

    }
    /**
     * 新增房间
     *
     * @param room
     * @return
     */
    @PostMapping("/addRoom")
    @ResponseBody
    public Response addRoom(@RequestBody Room room) {

        return Response.success(roomService.addRoom(room));

    }
    /**
     * 修改房型
     *
     * @param room
     * @return
     */
    @PostMapping("/updateRoom")
    @ResponseBody
    public Response updateRoom(@RequestBody Room room) {
        return Response.success(roomService.updateRoom(room));

    }

    /**
     * 查询房间列表
     *
     * @param roomQuery
     * @return
     */
    @PostMapping("/getRoomList")
    @ResponseBody
    public PageInfo<Room> getRoomList(@RequestBody RoomQuery roomQuery) {
        return roomService.getRoomList(roomQuery);
    }



}
